export default {
  methods: {
    // 找出第一组有数据的位置下标
    getFirstDataIndex(option, len, seriesName = null) {
      let firstValueIndex = null;
      for (let i = 0; i < len; i++) {
        option.series.forEach((serie) => {
          if ((seriesName && serie.name === seriesName) || !seriesName) {
            if (
              (typeof serie.data[i] == "string" &&
                ![undefined, null, "-"].includes(serie.data[i])) ||
              (typeof serie.data[i] == "object" &&
                ![undefined, null, "-"].includes(serie.data[i].value))
            ) {
              firstValueIndex = i;
            }
          }
        });
        if (firstValueIndex != null) {
          break;
        }
      }
      return firstValueIndex;
    },
  },
};
